%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                           %
% JUAN LUIS VARONA,                                         %
% Dpto. de Matem\'aticas y Computaci\'on,                   %
% Universidad de La Rioja                                   %
%                                                           %
% e-mail (internet): jvarona@siur.unirioja.es               %
%                                                           %
%                                                           %
% BEGINNING DATE: 4 DE ABRIL DE 1995                        %
% LAST MODIFICATION DATE: 27 DE ABRIL DE 1995               %
%                                                           %
% Written with LaTeX 2.09                                   %
%                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentstyle[12pt]{article}


\title{A patch for text editors for\\ \TeX\ with Macintosh}

\author{Juan L. Varona\\
			{\footnotesize Departamento de Matem\'aticas y Computaci\'on}\\
			{\footnotesize Universidad de La Rioja}\\
   {\footnotesize 26004 Logro\~no, SPAIN}\\
   {\footnotesize e-mail: \tt jvarona@siur.unirioja.es}}
   
\date{Version 1.0. Date: 27 of April, 1995}


\begin{document}

\maketitle

This patch can be installed in any word processor that we use to write \TeX\
source code documents. It is designed to be installed with the program {\it Text
Editor Patches}, from James W. Walker. I would like to acknowledge him for
his help and kindness.

There are five categories of shortcuts:

\begin{enumerate}

\item We write Greek letters by using the option (or option and shift for
capitals) at same time that the similar Roman letter. This is also employed to
type several frequent mathematical symbols ($\nabla$, $\partial$, $\hbar$,
$\emptyset$, $\aleph$, $\times$).

\item We write vowels with accents pushing the accent key and the vowel. Also
\~n (and \~N), that is indeed written in \TeX\ as an accent, is considered in
this category. (Note, moreover, that in Spanish, it has his own key.)

\item We write non English characters (?`, !`, \c{c}, \ss, \aa, \o, \ae, \oe),
some mathematical symbols ($\le$, $\ge$, $\infty$, $\not=$, $\neg$, $\pm$,
$\bullet$, $\diamond$, $\div$, $\approx$, $\triangle$, $\int$) and other
special symbols (\dots, \copyright, \S, \P, \dag, \ddag) by typing the
corresponding keys in the Macintosh keyboard, as in any other application.
They are considerate less important than Greek letters, and they will not be
used if the position in the keyboard corresponds to the one assigned to a Greek
letter. But it is important to note that any useful letter in a language (for
instance, ?` in Spanish, \ss\ in German, \c{c} in Catalan and French, etc.) has
its own key in the corresponding keyboard, so they are not intercepted by any
Greek letter.

\item We use the function keys \verb+F5+, \verb+F6+, \verb+F7+ and \verb+F8+
to generate \verb+()+, \verb+[]+, \verb+{}+, and \verb+||+ respectively. Using
them with option we get \verb+\(\)+, \verb+\[\]+, \verb+\{\}+, and \verb+\|\|+.
(In all these cases, the cursor appears in the middle.) And, finally, pushing
also command, the selected text is surrounded by the corresponding delimiters.

\item Pushing the key with the number \verb+4+ (that, in many languages, also
has the symbol \verb+$+) at same time that command, we get \verb+$$+ with the
cursor in the middle. And pushing also option, the selected text is surrounded
by two \verb+$+.
(Note: In AZERTY and QZERTY keyboards, pushing the key with the symbol \verb+$+.)

\end{enumerate}

The first, fourth and fifth categories are related with the position of the key,
and the others by the ASCII code that is generated by the key (with the appropriate
modifiers). In any case, it is important to note that the shortcuts are inspected
in the order that we indicate below. That means, for instance, that, if in some
exotic keyboard the symbol $\infty$ is in the same key that the number \verb+4+,
it will not be possible to use the last shortcut. In practice, many of the symbols
it the third category cannot be obtained using the macros that we explain here
because they are previously interpreted as a Greek letter, that is is the first
category.

On the other hand, it is possible that, in some keyboards, some useful reserved
\TeX\ symbol is generated by pressing option (or option+shift) and a ordinary
letter. If it is the case, as we patch these combinations in the category one,
it would be impossible to obtain these symbol. This happens, for instance,
with the symbol \verb+^+, that in U.S. and in most Spanish keyboards is typed by
pushing option+\verb+i+. To avoid this undesirable mask, we must previously check
if we are generating a reserved \TeX\ symbol, and, in such way, not to allow the
patch. We have a exception to that: we allow the possible mask of \verb+@+, but
we assign for it the combination option+shift+\verb+c+ (we do it, because, in most
Spanish keyboards, it is located in option+\verb+g+, which we would like to use
for \verb+\gamma+.)


%-----------------------------------------------------
\section{Different languages.}
%-----------------------------------------------------

This macros works very well in Spanish and U.S. keyboards (below, we will comment
something about that). It is possible that we obtain unexpected results in
other languages. This is due to the different layout of the keyboards in 
the different countries.

Actually, the main problem is easily solvable. It is that there is four kind
of keyboards, namely (according the keys in his upper row under the numbers)
QWERTY, AZERTY, QWERTZ and QZERTY. Most countries uses QWERTY keyboards, as U.S.
and Spain. In France, it is used the AZERTY keyboards; in Germany, QWERTZ; and, in
Italy, it is QZERTY.

With respect to QWERTY keyboards, AZERTY changes \verb+a+ with \verb+q+ and
\verb+e+ with \verb+w+; and \verb+m+ is in another position, just at the right of
\verb+l+. QWERTZ keyboards changes \verb+z+ with \verb+y+. Finally, QZERTY
changes \verb+z+ with \verb+y+; and \verb+m+ is located as in AZERTY.

Of course, depending on the countries there are many other changes in the position
of some punctuation marks, accents and symbols, but it is not important for our
purposes. As ASCII symbols are always the same, we only have problems when we
assigned a macro to the position of a letter, but not when the macro is related
with the ASCII code. It is the case of Greek letters: we want to assign a Greek
letter to the push of option (or option+shift) and a key similar to the
Greek one, nevertheless which is the ASCII in this position.

To solve this problems we only need to do four kind of patches, one for any kind
of keyboard.

The same happens when we want to use command, or option+command, at same time
that the key with \verb+$+. But it is less important: it suffices to use the key
with the number \verb+4+ in it that, indeed, in U.S. and Spanish keyboards is
also the code with \verb+$+, but it is not necessary true in other keyboards.
Actually, this problem is only possible in QWERTY and QWERTZ keyboards; it
does not arise in AZERTY and QZERTY keyboards, where \verb+$+ is always in its
own key.

Finally, to make easy to write accents, we can take into account some new
possibilities. In many languages as in Spanish and French, there are accented
vowels and, to write them, there is in the keyboard some dead-keys with the
accent symbol: when we press the dead-key, the computer waits that we type a new
key that will be mixed with the last one generating the ASCII code for the
accented letter. So, to get \"u, we only need to push the dead-key with accent
symbol \"{} and then to press \verb+u+. But \TeX\ do not understand (at least,
directly) the symbol \"u, an we must generate is by typing \verb+\"u+. We want
that our word processor make this behavior by itself, and this is the object of
the second category of macros.

But, in many languages, like in English, there is not accented letters,
so, in the corresponding keyboards there are not dead-keys in a easily accessible
position. When it is the case, to generate a accented letter we can simulate the
last situation: we type, for instance the key with the symbol \"{} and it is
generated the code \verb+\"+. It has an advantage: it can be applied to any
letter and \TeX\ will write the letter with the accent; not only when the next
letter with the accent has, in the Macintosh, a symbol with a ASCII code.
But it has a disadvantage: it is not possible to distinguish when the letter to
accentuate is \verb+i+, and it is not possible to put out the point over it.
To solve this, we can redefine, for instance, the \TeX\ accent \verb+\'+ as
\begin{center}
    \verb+\def\'#1{\if#1i{\accent"13\i}\else{\accent"13 #1}\fi}+
\end{center}
and the point will be retired without problems. (Similar for accents \verb+\"+,
\verb+\^+, \verb+\`+ and \verb+\~+ putting, instead of \verb+13+, the
codes \verb+7F+, \verb+5E+, \verb+12+ and \verb+7E+ respectively.)

Remember that, when we use this kind of patch, the previous \TeX\ code MUST be
include in each \TeX\ file.

There is no any solution for \^{} and \`{} French accents (for non-dead
keys), because they are also useful \TeX\ symbols. Fortunately (for Spanish
people) these accents does not exist in Spanish.

When we are using a keyboard without dead-keys, or we can easily accent any
letter, it is better to use the second method, using the appropriate \TeX\
redefinition of the accent. So, two couples of files of macros are needed
according our preferences.

%-----------------------------------------------------
\section{Known problems.}
%-----------------------------------------------------

If you push a dead-key (that is, an accent) and a unexpected letter or
symbol, we obtain strange results. For instance, pushing the dead-key \'{} and
option+\verb+a+ we get \verb+\\alphaalpha+. And pushing \'{} and \verb+p+
we get \verb+\p'+. Of course, this has no sense for \TeX. But it is not
important: if we generate this undesirable code, we delete it and so on.

In U.S. keyboards, for instance, where some dead-keys are located in vowels
pushing also option, this prevent the use of some useful Greek letters, like
\verb+\varepsilon+.


%-----------------------------------------------------
\section{Tables.}
%-----------------------------------------------------

The complete relation of symbols and keys in all categories is the following:

%protected symbols

%\begin{table}[ht]
%\centering
%\begin{tabular}{|c|c|}
%\hline
%{\bf Characters}         & ASCII code    \\
%\hline
%\verb|!"#$%&'()*+,-./|   & 0x21 to 0x2F  \\
%\verb+:;<=>?+            & 0x3A to 0x3F  \\
%\verb+[\]^_`+            & 0x5B to 0x60  \\
%\verb+{|}~+              & 0x7B to 0x7E  \\
%\hline
%\end{tabular}
%\caption{Protected characters (reserved for \TeX)}
%\end{table}

\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
{\bf Characters}                                   & ASCII code    \\
\hline
\verb+!+, \verb+"+, \verb+#+, \verb+$+, \verb+%+, \verb+&+,
\verb+'+, \verb+(+, \verb+)+, \verb+*+, \verb|+|, \verb+,+
\verb+-+, \verb+.+, \verb+/+                       & 0x21 to 0x2F  \\
\verb+:+, \verb+;+, \verb+<+, \verb+=+, \verb+>+, \verb+?+
                                                   & 0x3A to 0x3F  \\
\verb+[+, \verb+\+, \verb+]+, \verb+^+, \verb+_+, \verb+`+
                                                   & 0x5B to 0x60  \\
\verb+{+, \verb+|+, \verb+}+, \verb+~+             & 0x7B to 0x7E  \\
\hline
\end{tabular}
\caption{Protected characters (reserved for \TeX)}
\end{table}

%-----------------------

%Greek leters

\begin{table}[ht]
\centering
\begin{tabular}{|c|c|c|}
\hline
{\bf Key} & with {\it option}            & with {\it option} + {\it shift} \\
\hline
\verb+a+ & \verb+\alpha+  ($\alpha$)     & \verb+\aleph+  ($\aleph$)       \\
\verb+b+ & \verb+\beta+  ($\beta$)       &   no macro                      \\
\verb+c+ & \verb+\chi+  ($\chi$)         & \verb+@+                        \\
\verb+d+ & \verb+\delta+  ($\delta$)     & \verb+\Delta+  ($\Delta$)       \\
\verb+e+ & \verb+\varepsilon+  ($\varepsilon$)
                                         & \verb+\epsilon+  ($\epsilon$)   \\
\verb+f+ & \verb+\phi+  ($\phi$)         & \verb+\Phi+  ($\Phi$)           \\
\verb+g+ & \verb+\gamma+  ($\gamma$)     & \verb+\Gamma+  ($\Gamma$)       \\
\verb+h+ & \verb+\eta+  ($\eta$)         & \verb+\hbar+  ($\hbar$)         \\
\verb+i+ & \verb+\iota+  ($\iota$)       & \verb+\int+  ($\int$)           \\
\verb+j+ & \verb+\varphi+  ($\varphi$)   & \verb+\iota+  ($\iota$)         \\
\verb+k+ & \verb+\kappa+  ($\kappa$)     & \verb+\varsigma+  ($\varsigma$) \\
\verb+l+ & \verb+\lambda+  ($\lambda$)   & \verb+\Lambda+  ($\Lambda$)     \\
\verb+m+ & \verb+\mu+  ($\mu$)           &   no macro                      \\
\verb+n+ & \verb+\nu+  ($\nu$)           &   no macro                      \\
\verb+o+ & \verb+\partial+  ($\partial$) & \verb+\emptyset+  ($\emptyset$) \\
\verb+p+ & \verb+\pi+  ($\pi$)           & \verb+\Pi+  ($\Pi$)             \\
\verb+q+ & \verb+\theta+  ($\theta$)     & \verb+\Theta+  ($\Theta$)       \\
\verb+r+ & \verb+\rho+  ($\rho$)         & \verb+\varrho+  ($\varrho$)     \\
\verb+s+ & \verb+\sigma+  ($\sigma$)     & \verb+\Sigma+  ($\Sigma$)       \\
\verb+t+ & \verb+\tau+  ($\tau$)         & \verb+\times+  ($\times$)       \\
\verb+u+ & \verb+\upsilon+  ($\upsilon$) & \verb+\Upsilon+  ($\Upsilon$)   \\
\verb+v+ & \verb+\varpi+  ($\varpi$)     & \verb+\nabla+  ($\nabla$)       \\
\verb+w+ & \verb+\omega+  ($\omega$)     & \verb+\Omega+  ($\Omega$)       \\
\verb+x+ & \verb+\xi+  ($\xi$)           & \verb+\Xi+  ($\Xi$)             \\
\verb+y+ & \verb+\psi+  ($\psi$)         & \verb+\Psi+  ($\Psi$)           \\
\verb+z+ & \verb+\zeta+  ($\zeta$)       & \verb+\vartheta+  ($\vartheta$) \\
\hline
\end{tabular}
\caption{Greek letters and several frequent mathematical symbols}
\end{table}

%-----------------------

%Accents

\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
{\bf Pushing}                     & we get                         \\
\hline
\'{} (non-dead key)               & \verb+\'+                      \\
\"{} (non-dead key)               & \verb+\"+                      \\
\'a, \'e, \'\i, \'o, \'u          &
     \verb+\'a+, \verb+\'e+, \verb+\'i+, \verb+\'o+, \verb+\'u+    \\
\'A, \'E, \'I,  \'O, \'U          &
     \verb+\'A+, \verb+\'E+, \verb+\'I+, \verb+\'O+, \verb+\'U+    \\
\"a, \"e, \"\i, \"o, \"u, \"y     &
     \verb+\"a+, \verb+\"e+, \verb+\"i+, \verb+\"o+, \verb+\"u+,
     \verb+\"y+                                                    \\
\"A, \"E, \"I,  \"O, \"U, \"Y     &
     \verb+\"A+, \verb+\"E+, \verb+\"I+, \verb+\"O+, \verb+\"U+,
     \verb+\"Y+                                                    \\
\`a, \`e, \`\i, \`o, \`u          &
     \verb+\`a+, \verb+\`e+, \verb+\`i+, \verb+\`o+, \verb+\`u+    \\
\`A, \`E, \`I,  \`O, \`U          &
     \verb+\`A+, \verb+\`E+, \verb+\`I+, \verb+\`O+, \verb+\`U+    \\
\^a, \^e, \^\i, \^o, \^u          &
     \verb+\^a+, \verb+\^e+, \verb+\^i+, \verb+\^o+, \verb+\^u+    \\
\^A, \^E, \^I,  \^O, \^U          &
     \verb+\^A+, \verb+\^E+, \verb+\^I+, \verb+\^O+, \verb+\^U+    \\
\~a, \~o, \~n                     &
     \verb+\~a+, \verb+\~o+, \verb+\~n+                            \\
\~A, \~O, \~N                     &
     \verb+\~A+, \verb+\~O+, \verb+\~N+                            \\
\hline
\end{tabular}
\caption{Accents}
\end{table}

%-----------------------

%non English characters (?`, !`, \c{c}, \ss, \aa, \o, \ae, \oe),

\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
{\bf Pushing (ASCII)}         & we get                      \\
\hline
?`           \ \ (0xC0)       & \verb+?`+                   \\
!`           \ \ (0xC1)       & \verb+!`+                   \\
\c{c}, \c{C} \ \ (0x8D, 0x82) & \verb+\c{c}+, \verb+\c{C}+  \\
\ss          \ \ (0xA7)       & \verb+\ss+                  \\
\aa,   \AA   \ \ (0x8C, 0x81) & \verb+\aa+,   \verb+\AA+    \\
\o,    \O    \ \ (0xBF, 0xAF) & \verb+\o+,    \verb+\O+     \\
\ae,   \AE   \ \ (0xAE, 0xBE) & \verb+\ae+,   \verb+\AE+    \\
\oe,   \OE   \ \ (0xCF, 0xCE) & \verb+\oe+,   \verb+\OE+    \\
\hline
\end{tabular}
\caption{Non English characters}
\end{table}

%-----------------------

%some mathematical symbols ($\le$, $\ge$, $\infty$, $\not=$, $\neg$, $\pm$,
%$\bullet$, $\diamond$, $\div$, $\approx$, $\triangle$, $\int$) and other

\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
{\bf Pushing (ASCII)}  & we get           \\
\hline
$\le$    \ \ (0xB2)    & \verb+\le+       \\
$\ge$    \ \ (0xB3)    & \verb+\ge+       \\
$\infty$ \ \ (0xB0)    & \verb+\infty+    \\
$\not=$  \ \ (0xAD)    & \verb+\not=+     \\
$\neg$   \ \ (0xC2)    & \verb+\neg+      \\
$\pm$    \ \ (0xB1)    & \verb+\pm+       \\
\hline
\end{tabular}
\qquad
\begin{tabular}{|c|c|}
\hline
{\bf Pushing (ASCII)}    & we get             \\
\hline
$\bullet$   \ \ (0xA5)   & \verb+\bullet+     \\
$\diamond$  \ \ (0xD7)   & \verb+\diamond+    \\
$\div$      \ \ (0xD6)   & \verb+\div+        \\
$\approx$   \ \ (0xC5)   & \verb+\approx+     \\
$\triangle$ \ \ (0xC6)   & \verb+\triangle+   \\
$\int$      \ \ (0xBA)   & \verb+\int+        \\
\hline
\end{tabular}
\caption{Some mathematical symbols}
\end{table}

%-----------------------

%Other special symbols (\dots, \copyright, \S, \P, \dag, \ddag)

\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
{\bf Pushing (ASCII)}  & we get             \\
\hline
\dots      \ \ (0xC9)  & \verb+\dots+       \\
\copyright \ \ (0xA9)  & \verb+\copyright+  \\
\S         \ \ (0xA4)  & \verb+\S+          \\
\P         \ \ (0xA6)  & \verb+\P+          \\
\dag       \ \ (0xA0)  & \verb+\dag+        \\
\ddag      \ \ (0xE0)  & \verb+\ddag+       \\
\hline
\end{tabular}
\caption{Other special symbols}
\end{table}

%-----------------------

\end{document}